package com.onpositive.html.model;

import java.util.ArrayList;

public class Table {
	
	private String title;
	
	private String caption;
	
	private ArrayList<ArrayList<String>> headers = new ArrayList<ArrayList<String>>();
	
	public void addHeadersArray(ArrayList<String> lst){
		headers.add(lst);
	}	
	
	private ArrayList<ArrayList<ITableEntry>> columns = new ArrayList<ArrayList<ITableEntry>>();
	
	public void setColumnsCount(int count){
		
		int min = Math.min(count, columns.size());
		for(int i = 0 ; i < min ; i++ ){
			if(columns.get(i)==null)
				columns.set(i, new ArrayList<ITableEntry>());
		}
		for(int i = min ; i < count ; i++ ){
			columns.add(new ArrayList<ITableEntry>());
		}
	}

	public ArrayList<ArrayList<String>> getHeaders() {
		return headers;
	}

	public ArrayList<ArrayList<ITableEntry>> getColumns() {
		return columns;
	}

	public void setTitle(String title) {
		this.title = title;		
	}

	public String getTitle() {
		return title;
	}

	public String getCaption() {
		return caption;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}
	
	@Override
	public String toString() {
		if(caption!=null)
			return caption;
		
		if(title!=null)
			return title;
		
		return super.toString();
	}
}
